package com.cddx.logistics.service.impl;

import com.cddx.logistics.domain.dto.QueryDTO;
import com.cddx.logistics.domain.pojo.Department;
import com.cddx.logistics.domain.pojo.Role;
import com.cddx.logistics.domain.vo.SelectObject;
import com.cddx.logistics.mapper.DepartmentMapper;
import com.cddx.logistics.service.DepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Resource
    private DepartmentMapper departmentMapper;


    @Override
    public boolean addDepartment(Department department) {
        return departmentMapper.addDepartment(department) > 0;
    }

    @Override
    public boolean updateDepartment(Department department) {
        return departmentMapper.updateDepartment(department) > 0;
    }

    @Override
    public boolean deleteDepartment(Integer id) {
        return departmentMapper.deleteDepartment(id) >0;
    }

    @Override
    public PageInfo<Department> queryPage(QueryDTO queryDTO){
        PageHelper.startPage(queryDTO.getPage(), queryDTO.getLimit());
        List<Department> list = departmentMapper.queryPage(queryDTO);
        return new PageInfo<>(list);
    }

    @Override
    public List<SelectObject> queryAll() {
        return departmentMapper.queryAll();
    }

    @Override
    public boolean deleteIds(Integer[] ids) {
        return departmentMapper.deleteIds(ids) > 0;
    }
}
